package com.webridge.plm.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import wt.enterprise.EnterpriseHelper;
import wt.inf.container.WTContainerRef;
import wt.rule.algorithm.RuleAlgorithm;
import wt.util.WTException;
/**
 * 更新PART的OIR，设置编号为PN+日期年月+流水码
 * 
 * @author kira
 */
public class PartNumberRule implements RuleAlgorithm{

    @Override
    public Object calculate(Object[] arg0, WTContainerRef arg1) throws WTException {
        String number = "";
        String num = EnterpriseHelper.getNumber(arg0);
        System.out.println("OOTB NUM:" + num);
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String dateStr = sdf.format(date);
        number = dateStr.substring(0,6);
        return "PN"+number+num;
    }
    public static void main(String[] args) {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String dateStr = sdf.format(date);
        System.out.println("dateStr:" + dateStr.substring(0,6));
    }

}
